<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">


<div th:replace="public/base_update :: html"></div>

<body>
<!-- Start Page Loading -->
<div id="loader-wrapper">
    <div id="loader"></div>
    <div class="loader-section section-left"></div>
    <div class="loader-section section-right"></div>
</div>
<!-- End Page Loading -->


<!-- START MAIN -->
<!-- START WRAPPER -->


<!-- START CONTENT -->
<section id="content">
    <!--Form Advance-->
    <div class="row">
        <div class="col s12 m12 l12">
            <div class="card-panel">
                <h4 class="header2">仓库信息</h4>
                <div class="row">
                    <form class="col s12" id="send_form" action="">
                        <input type="hidden" id="id" name="id" th:value="${store.id}">
                        <div class="row">
                            <div class="input-field col s4">
                                <input id="name" name="name" type="text" th:value="${store.name}" />
                                <label for="name">仓库名称</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s4">
                                <input id="location" name="location" type="text" th:value="${store.location}" />
                                <label for="location">仓库位置</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s4">
                                <input id="capacity" name="capacity" type="text" th:value="${store.capacity}" />
                                <label for="capacity">仓库容量</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="input-field col s12">
                                <button id="send_btn" class="btn cyan waves-effect waves-light right" type="button"
                                        name="action">提交
                                    <i class="mdi-content-send right"></i>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>


<!-- ================================================
Scripts
================================================ -->

<script th:inline="javascript">

    $("#send_btn").click(function () {
        dialog.confirm('确定提交么?', function (index, layero) {
            var send_form = $('#send_form').serialize();
            console.log(send_form);
            $.ajax({
                type: "post",
                data: send_form,
                url: "/store/add",
                dataType: "json",
                success: function (msg) {
                    if (msg.success) {
                        Materialize.toast(msg.message, 500,'',function () {
                            dialog.parentclose(true)
                        });
                    } else {
                        Materialize.toast(msg.message, 3000);
                    }
                },
                error: function ( ) {
                    Materialize.toast("网络异常");
                }
            });
        });
    });
</script>

</body>

</html>
